Return to doc.sitecore.com

6.  Override the HandleMessage Method
Prev Next

If some of the fields in your control should handle messages (such as Select All, Invert, etc.), override the HandleMessage method and delegate messages to appropriate fields.

1 public override void HandleMessage(Sitecore.Web.UI.Sheer.Message message)
2       {
3         
4          if(message["id"] == this.ID)
5          {
6             Sitecore.Shell.Applications.ContentEditor.Checklist list = FindControl(GetID("list")) as Sitecore.Shell.Applications.ContentEditor.Checklist;
7             Sitecore.Shell.Applications.ContentEditor.Text text = FindControl(GetID("text")) as Sitecore.Shell.Applications.ContentEditor.Text;
8             if(list != null)
9             {
10                string messageText;
11                if ((messageText = message.Name) == null)
12                {
13                   return;
14                }
15
16                if (messageText != "checklist:checkall")
17                {
18                   if (messageText == "checklist:uncheckall")
19                   {
20                      list.UncheckAll();
21                   }
22                   else if (messageText == "checklist:invert")
23                   {
24                      list.Invert();
25                   }
26                }
27                else
28                {
29                   list.CheckAll();
30                }
31             }
32          }
33
34          base.HandleMessage (message);
35       }

Prev Next